import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import { useUserStore } from './stores/user'

// 清除所有存储的状态
localStorage.clear()

// 创建应用实例
const app = createApp(App)

// 创建 Pinia 实例
const pinia = createPinia()
app.use(pinia)

// 初始化用户状态
const userStore = useUserStore()
userStore.initializeStore()

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 按照顺序使用插件
app.use(ElementPlus)    // 再初始化 Element Plus
app.use(router)         // 最后初始化路由

// 挂载应用
app.mount('#app')

// 输出路由信息以便调试
console.log('Current routes:', router.getRoutes())
